package com.example.framework2002.mvvm;

import androidx.lifecycle.MutableLiveData;

import com.example.framework2002.kind.Fenl;
import com.example.lib_cson.mvvm.vm.BaseViewModel;

import java.util.List;
import io.reactivex.Observer;
import io.reactivex.disposables.Disposable;

public class MyViewModel extends BaseViewModel<MyRepository> {
    public MyViewModel(MyRepository mRepository) {
        super(mRepository);
    }
    public MyRepository getRepository(){
        return mRepository;
    }

    private MutableLiveData<List<Fenl.DataBean>> liveData=new MutableLiveData<>();

    public MutableLiveData<List<Fenl.DataBean>> getLiveData() {
        return liveData;
    }

    private MutableLiveData<List<Fenl.DataBean>> liveData2=new MutableLiveData<>();


    public void getData(int type){
        getRepository().getModel().getFen(new Observer<Fenl>() {
            @Override
            public void onSubscribe(Disposable d) {

            }

            @Override
            public void onNext(Fenl fenl) {
                liveData.postValue(fenl.getData());
            }

            @Override
            public void onError(Throwable e) {

            }

            @Override
            public void onComplete() {

            }
        },type);
    }

    public void getData2(int type){
        getRepository().getModel().getFen(new Observer<Fenl>() {
            @Override
            public void onSubscribe(Disposable d) {

            }

            @Override
            public void onNext(Fenl fenl) {
                liveData2.postValue(fenl.getData());
            }

            @Override
            public void onError(Throwable e) {

            }

            @Override
            public void onComplete() {

            }
        },type);
    }

    public void getData3(int type){
       getRepository().getModel().getFen(new Observer<Fenl>() {
           @Override
           public void onSubscribe(Disposable d) {

           }

           @Override
           public void onNext(Fenl fenl) {

           }

           @Override
           public void onError(Throwable e) {

           }

           @Override
           public void onComplete() {

           }
       },type);

    }
}
